//package com.pks.datacenter.controller.api;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.context.annotation.Scope;
//import org.springframework.stereotype.Component;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.pks.datacenter.entity.api.ApiToken;
//import com.pks.datacenter.service.api.ApiTokenService;
//import com.pks.resultful.common.SRemoteResult;
//import com.pks.util.UtilConvert;
//import com.pks.util.UtilString;
//import com.pks.web.springmvc.controller.BasicController;
//
//
//@RestController
//@RequestMapping(value = "/apiToken")
//@Scope("prototype")
//@Component("apiTokenController")
//@Api(tags = "接口apiToken")
//public class ApiTokenController extends BasicController {
//
//	@Resource
//	private ApiTokenService apiTokenService;
//
//	@ApiOperation(value = "删除记录")
//	@RequestMapping(value = "/delete" , method = RequestMethod.DELETE)
//	public SRemoteResult<String> delete(HttpServletRequest request, String ids) {
//		if (UtilString.isBlank(ids)) {
//			return SRemoteResult.initErrorParamBlank(null);
//		}
//		if (StringUtils.isBlank(ids) || !ids.matches("^[0-9]+(,[0-9]+)*$")) {
//			return SRemoteResult.initErrorParamInvalid(null);
//		}
//		List<Long> idList = UtilConvert.string2LongList(ids);
//		if (idList.size() == 1) {
//			apiTokenService.delete(idList.get(0));
//		} else {
//			apiTokenService.deleteByIds(idList);
//		}
//		return SRemoteResult.initSuccess(null);
//	}
//	
//	@ApiOperation(value = "新增或修改")
//	@RequestMapping(value = "/modify" , method = RequestMethod.POST)
//	public SRemoteResult<String> modify(HttpServletRequest request, ApiToken obj) {
//		if (obj == null) {
//			return SRemoteResult.initErrorParamMissing(null);
//		}
//		if (obj.getId() == null) {
//			obj.insertBefore();
//			apiTokenService.insert(obj);
//		} else {
//			ApiToken update = apiTokenService.findById(obj.getId());
//			if (update == null) {
//				return SRemoteResult.initErrorDataNone();
//			}
//			apiTokenService.update(obj);
//		}
//		return SRemoteResult.initSuccess(null);
//	}
//
//	@ApiOperation(value = "获取详情")
//	@ApiImplicitParams({
//		@ApiImplicitParam(name = "id",value = "id", dataType = "long" , paramType = "query" )
//	})
//	@RequestMapping(value = "/get" , method = RequestMethod.GET)
//	public SRemoteResult<ApiToken> findInfo(HttpServletRequest request, Long id) {
//		if (id == null) {
//			return SRemoteResult.initErrorParamMissing(null);
//		}
//		ApiToken obj = apiTokenService.findById(id);
//		if (obj == null) {
//			return SRemoteResult.initErrorDataNone();
//		}
//		return SRemoteResult.initSuccess(obj);
//	}
//
//	@ApiOperation(value = "列表查询")
//	@ApiImplicitParams({
//		@ApiImplicitParam(name = "apiToken",value = "apiToken", dataType = "String" , paramType = "query" )
//		,@ApiImplicitParam(name = "apiUserId",value = "接口帐号（apiuser）id", dataType = "Long" , paramType = "query" )
//		,@ApiImplicitParam(name = "offset",value = "分页起始页（默认0）", dataType = "int" , paramType = "query" )
//		,@ApiImplicitParam(name = "pagesize",value = "分页每页行数（默认10）", dataType = "int" , paramType = "query" )
//	})
//	@RequestMapping(value = "/list" , method = RequestMethod.POST)
//	public SRemoteResult<List<ApiToken>> list(HttpServletRequest request,String apiToken ,Long apiUserId  ,Integer offset,Integer pagesize) {
//		Map<String, Object> qbuilder = new HashMap<String, Object>();
//		if (UtilString.isNotBlank(apiToken)) {
//			qbuilder.put("apiToken", apiToken);
//		}
//		if (apiUserId != null) {
//			qbuilder.put("apiUserId", apiUserId);
//		}
//		List<ApiToken> list = new ArrayList<ApiToken>();
//		int total = 0;
//		total = apiTokenService.getTotalRows(qbuilder);
//		if (total > 0) {
//			list = apiTokenService.findByPage(null, qbuilder);
//		}
//		return SRemoteResult.initPageList(list, total);
//	}
//
//
//    @ApiOperation(value = "数据查询（不分页）")
//    @ApiImplicitParams({
//        @ApiImplicitParam(name = "apiToken",value = "apiToken", dataType = "String" , paramType = "query" )
//        ,@ApiImplicitParam(name = "apiUserId",value = "接口帐号（apiuser）id", dataType = "Long" , paramType = "query" )
//    })
//    @RequestMapping(value = "/data" , method = RequestMethod.POST)
//    public SRemoteResult<List<ApiToken>> data(HttpServletRequest request,String apiToken ,Long apiUserId  ) {
//        Map<String, Object> qbuilder = new HashMap<String, Object>();
//        if (UtilString.isNotBlank(apiToken)) {
//            qbuilder.put("apiToken", apiToken);
//        }
//        if (apiUserId != null) {
//            qbuilder.put("apiUserId", apiUserId);
//        }
//        List<ApiToken> list = new ArrayList<ApiToken>();
//        list = apiTokenService.find(null, qbuilder, null);
//        return SRemoteResult.initPageList(list, null);
//    }
//
//
//}
